package guestbook.persistencia;

import com.google.appengine.api.datastore.Key;
import guestbook.dao.SaludoDAO;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;


import java.io.Serializable;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.springframework.stereotype.Component;

@Entity
@Component
public class Saludo implements Serializable {

    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Basic
    private String author;
    @Basic
    private String content;
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    @OneToMany(mappedBy = "saludo", cascade = CascadeType.ALL)
    private List<Voto> votos = new ArrayList<Voto>();

    public Saludo() {
    }

    public Saludo(Usuario author, String content, Date fecha) {
        if (author != null) {
            this.author = author.getUsername();
        }
        this.content = content;
        this.fecha = fecha;
    }



    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    
    

    public String getContent() {
        return content;
    }

    public Date getFecha() {
        return fecha;
    }

    

    public void setContent(String content) {
        this.content = content;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public List<Voto> getVotos() {
        return votos;
    }

    public void setVotos(List<Voto> votos) {
        this.votos = votos;
    }

}
